package com.lkm.market2_0.m_imple.steelyardserver.server.cmd_handle;

import android.os.Handler;
import android.os.Looper;

import com.google.gson.Gson;
import com.lkm.frame.P;
import com.lkm.market2_0.ExpandConfig;
import com.lkm.market2_0.entity.SteelyardInfo;
import com.lkm.market2_0.help.SteelardHelp;
import com.lkm.market2_0.help.UIP;
import com.lkm.market2_0.m.steelyarddata.OrderEntity;
import com.lkm.market2_0.m.steelyarddata.SteelyardDataModule;
import com.lkm.market2_0.m.steelyardserver.OnSteelyardKeyEvent;
import com.lkm.market2_0.m.steelyardserver.SteelyardServerModule;
import com.lkm.market2_0.m.steelyardserver.to.WeightChangeInfo;
import com.lkm.market2_0.m_imple.steelyardserver.WeightChangeHelp;
import com.lkm.market2_0.m_imple.steelyardserver.server.AbsReceiverDataHandle;
import com.lkm.market2_0.m_imple.steelyardserver.server.CMDEntity;
import com.lkm.market2_0.m_imple.steelyardserver.server.ICMDHandle;




public class CMDScanAndDelegatePayHandle implements ICMDHandle {
    SteelyardDataModule mSteelyardDataModule;

    Handler handler = null;

    public CMDScanAndDelegatePayHandle() {
        handler = new Handler(Looper.getMainLooper());
        this.mSteelyardDataModule = ExpandConfig.instance.getModuleManager().loadModule(SteelyardDataModule.class);
    }

    @Override
    public AbsReceiverDataHandle handle(CMDEntity cmdEntity) {

        if(this.mSteelyardDataModule==null)
        this.mSteelyardDataModule = ExpandConfig.instance.getModuleManager().loadModule(SteelyardDataModule.class);


        SteelyardInfo steelyardInfo = mSteelyardDataModule.getSteelyardInfo(cmdEntity.getSteelyardMac());


        if(steelyardInfo == null){
            return null;
        }

        
        if(steelyardInfo.hasState(SteelyardInfo.RunTimeState_subtotal)) {

            if(ExpandConfig.instance.isUI()){


                
                OnSteelyardKeyEvent.sendKey(cmdEntity.getCmd(), handler);
            }
        }

        
        steelyardInfo.removeState(SteelyardInfo.RunTimeState_subtotal);

        return null;
    }




}
